Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully statically linked skyscope binary #94

Merged
merged 7 commits into from
Aug 15, 2023
Merged

Conversation

aherrmann
Copy link
Member

@aherrmann aherrmann commented Jun 11, 2023

This uses rules_haskell's capability for fully static linking together with static libraries and an appropriate GHC provided by static-haskell-nix and patched as described in this blog post.

A build on Linux confirms that the resulting library is fully static and is functional.

$ file bazel-bin/backend/skyscope
bazel-bin/backend/skyscope: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped

What's missing to be able to merge this is (at least) to have the appropriate GHC, GCC, zlib, etc. in a Nix cache.

Warning: If you test this locally this will build GHC via Nix. You can use a remote builder configured in /etc/nix/machines to speed it up.

cc @nh2 @jonathanlking

@benradf
Copy link
Member

benradf commented Jun 12, 2023

This is awesome, thanks!

What's missing to be able to merge this is (at least) to have the appropriate GHC, GCC, zlib, etc. in a Nix cache.

Even having to build GHC etc in full, the convenience of distributing a single statically linked binary is worth it IMO.

@aherrmann
Copy link
Member Author

Relevant static-haskell-nix upstream work: nh2/static-haskell-nix@c91a9b4, nh2/static-haskell-nix#116

@aherrmann
Copy link
Member Author

Even having to build GHC etc in full, the convenience of distributing a single statically linked binary is worth it IMO.

Yes, just need to figure out how to build it without timing out CI in that case. Maybe we can connect CI to a Nix remote builder?

As static-haskell-nix doesn't yet support MacOS, and as we don't have a Nix
cache with an appropriate GHC, it will be convenient to allow both types of
linking for the time being.

The default will be to link dynamically. To build a fully static binary pass:
    --host_platform=//backend:static_executable
@benradf benradf marked this pull request as ready for review August 15, 2023 10:39
@benradf benradf merged commit 98fb311 into tweag:master Aug 15, 2023
4 checks passed
@aherrmann aherrmann deleted the static branch October 4, 2023 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants